﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using makitRS.Core.Models.Reports;
using makitRS.Core.Data;
using System.Data.Entity;

namespace makitRS.Core.Reports
{
    public class ReportManager
    {
        static ReportList list = new ReportList();

        public static Category getCategory(int id)
        {
            var cat = from c in list.Categories
                      where c.CategoryID == id
                      select c;

            if (cat.Count() > 0)
                return cat.Single();
            else
                return null;
        }

        public static Report getReport(int id)
        {
            var rep = from r in list.Reports
                      where r.ReportID == id
                      select r;

            if (rep.Count() > 0)
                return rep.Single();
            else
                return null;
        }

        public static void initData()
        {
            Database.SetInitializer<ReportList>(new SampleDataInitializer());

        }

        //public static List<Report> getLast30DayReports()
        //{
        //    DateTime repsFrom = DateTime.Today.AddDays(-30);

        //    var reports = from r in list.Reports
        //                  where r.ReportDateTime > repsFrom
        //                  select r;

        //    return reports.ToList();
        //}

        //public static void addDownloadableReport(DownloadableReport rep)
        //{
        //    list.Reports.Add(rep);
        //    list.SaveChanges();
        //}
    }
}
